Seam-based reduction and expansion of images using parallel processing of retargeting matrix strips

ABSTRACT

Systems, methods, and computer-readable storage media for resizing images using seam carving techniques may access a pre-computed retargeting matrix for an input image that associates each pixel of the input image with a cost order of a horizontal and/or vertical seam of which the pixel is a part. The retargeting matrix may be divided into sub-matrices corresponding to horizontal or vertical strips of the image, in the direction of a desired seam carving operation, for parallel processing on multiple processors or threads thereof. The retargeting matrix and/or sub-matrices may be usable in performing one or more reduction or expansion operations on the input image without re-computation of the matrices between retargeting iterations. The methods may include pre-computing the retargeting matrix and/or sub-matrices. The methods may be implemented as stand-alone applications or as program instructions implementing components of a graphics application, executable by a CPU and/or GPU configured for parallel processing.

BACKGROUND Description of the Related Art

The diversity and versatility of display devices today imposes new demands on digital media. For instance, designers must create different alternatives for web-content and design different layouts for different devices. Moreover, HTML, as well as other standards, can support dynamic changes of page layout and text. Images, although they make up some of the key elements in digital media, typically remain rigid in size and cannot deform to fit different layouts automatically. However, the size and/or aspect ratio of an image must change in order to fit into different displays, such as cell phones or PDAs, or to print on a given paper size or at a specified resolution.

Resizing images using standard image scaling is often not sufficient since it is oblivious to the image content and typically can be applied only uniformly, resulting in various artifacts or distortions of the input image. Cropping is also of limited use since it can only remove pixels from the image periphery. More effective resizing can only be achieved by considering the image content and not only geometric constraints. Seam carving techniques have been developed which alter the dimensions of an image by removing pixels from the image or adding pixels to the image that are considered to be less important than other pixels of the image, e.g., based on a pixel's value as compared to the value of its neighbors. However, standard seam carving techniques may be computationally expensive and may also produce undesirable artifacts or distortions. In addition, the number of computations performed using standard seam carving techniques may make them too slow for use in fluid user-interactive environments.

SUMMARY

Systems, methods, and computer-readable storage media for resizing images using seam carving techniques may access a pre-computed retargeting matrix for an input image that associates each pixel of the input image with a corresponding cost-ordered horizontal and/or vertical seam of which the pixel is a part. The retargeting matrix may in various embodiments be divided into sub-matrices corresponding to horizontal or vertical strips of the image, in the direction of a desired seam carving operation, for independent and concurrent (i.e., parallel) processing on multiple processors or threads thereof to retarget the input image. The retargeting matrix and/or sub-matrices may be usable in performing one or more reduction or expansion operations on the input image without re-computation of the matrices between retargeting iterations. In some embodiments, the retargeting matrix and/or sub-matrices may be generated in response to opening or accessing an input image in a graphics application, or in response to a request to resize an input image. In other embodiments, the retargeting matrix may be provided to a graphics application along with the input image (e.g., by a third party provider of the image, or in response to its generation and storage during a previous use of the image). The methods may be implemented as stand-alone applications or as program instructions implementing components of a graphics application, executable by a CPU and/or GPU configured for parallel processing.

In some embodiments, the methods described herein may include generating an energy map for an input image by determining a respective energy value for each pixel of the image. In various embodiments, the respective energy values may be computed as a difference in color values of two or more pixels, a difference in intensity values of two or more pixels, a derivative of two or more pixel values, an average of two or more pixel values, a maximum of two or more pixel values, or a minimum of two or more pixel values.

The methods may also include identifying seams of the input image having the lowest costs, dependent on the respective energy values of pixels of the seam, where the cost of each seam is dependent on a sum of the respective energy values of all pixels of the seam, an average of the respective energy values of all pixels of the seam, a weighted average of the respective energy values of all pixels of the seam, or a maximum value of the respective energy values of all pixels of the seam, for example. Identifying the lowest cost seams may in some embodiments include identifying the shortest paths across the image or applying a dynamic programming technique.

In some embodiments, the methods described herein may be used to pre-compute a retargeting matrix, which may then be used in performing one or more retargeting operations on an input image without re-computing the energy and/or the lowest cost seam(s) of the image between iterations. In various embodiments, the retargeting matrix may store, for each seam, an identifier of the seam, an indication of the seam cost, a cost order of the seam, and/or an identifier of each of the pixels of the seam. In other embodiments, the retargeting matrix may store, for each pixel, an identifier of a horizontal or a vertical seam of which it is a part, and a cost of the seam(s) of which it is a part.

The methods may include performing a resizing operation on the image along one or more low cost seams, thus retargeting the image for display using a different size and/or aspect ratio. For example, the resizing operation may be a reduction operation, and the pixels of the identified seam(s) may be removed. In another example, the resizing operation may be an expansion operation, and the pixels of the identified seam(s) may be replicated in the image. The retargeting operation may be configured to identify and remove or replicate identified pixels by parallel processing each of a plurality of sub-matrices corresponding to strips of the image, e.g., by searching each sub-matrix for pixels associated with an indication of the lowest-cost seam or seams, and removing or replicating them in the image to produce a resized image.

The methods described herein may be implemented as program instructions, (e.g., stored on computer-readable storage media) executable by a CPU and/or GPU configured for parallel processing, in various embodiments. For example, they may be implemented as program instructions that, when executed, implement generating a retargeting matrix and/or performing a seam carving operation using parallel processing of sub-matrices thereof as stand-alone operations or in conjunction with execution of an image editing operation in a graphics application, in different embodiments.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1A illustrates two seams of an input image to be resized, according to one embodiment.

FIG. 1B illustrates an output image after resizing, according to one embodiment.

FIG. 2 is a flow diagram illustrating a method for resizing images along seams, according to various embodiments.

FIG. 3 is a flow diagram illustrating a method for generating a retargeting matrix for use in subsequent image retargeting operations, according to one embodiment.

FIG. 4 is a flow diagram illustrating a method for performing parallel processing of a retargeting matrix in an image resizing operation, according to one embodiment.

FIG. 5 illustrates a computer system configured to implement resizing of input images, according to one embodiment.

While several embodiments and illustrative drawings are included herein, those skilled in the art will recognize that embodiments are not limited to the embodiments or drawings described. It should be understood, that the drawings and detailed description thereto are not intended to limit embodiments to the particular forms disclosed, but on the contrary, the intention is to cover all modifications, equivalents and alternatives falling within the spirit and scope as defined by the appended claims. Any headings used herein are for organizational purposes only and are not meant to limit the scope of the description or the claims. As used herein, the word “may” is used in a permissive sense (i.e., meaning having the potential to), rather than the mandatory sense (i.e., meaning must). Similarly, the words “include”, “including”, and “includes” mean including, but not limited to.

DETAILED DESCRIPTION OF EMBODIMENTS

Graphic applications include an ever-increasing number of image editing features, such as various filtering options and resizing operations (e.g., for cropping, expanding, or reducing an image). Currently available image resizing techniques include scaling techniques and seam-based techniques, also known as seam carving techniques. Seam carving, as described herein, may be used to increase or decrease the size of an image, in various embodiments. For example, given an image, to reduce the width, one or more seams in the image may be identified by a seam carving technique and removed from the image, while to increase the width one or more seams may be identified and replicated in the image. As used herein, the term “seam” refers to a set of pixels along a path from one edge of the image (e.g., the top of the image) to the opposite edge of the image (e.g., the bottom of the image) that satisfies the following two constraints:

-   -   1) The seam is monotonic, meaning (in this example) that its         path only goes in one direction across the image (e.g., down),         and does not reverse directions as it crosses the image (e.g.,         going down for a while and then up, or vice versa).     -   2) The seam comprises pixels that are “connected” to each other.         In other words, for any given pixel of the seam (in this         example), the pixel on the next row must be either directly         below the given pixel or diagonally adjacent to the given pixel         (e.g., one pixel to the left of the pixel or one pixel to the         right of the given pixel on the next row). For example, from any         given pixel of the seam to the next pixel of the seam, the path         cannot jump to a pixel 20 pixels away in the next row.

In various embodiments, seam carving techniques may be content sensitive, or context aware. For example, given an input image, the data representing the image may be processed to generate an alternate representation of the image, which may be referred to as an energy map, which indicates the importance of each pixel in terms of image resizing. In some embodiments of a content-aware seam carving technique, the values mapped to each pixel of the input image by this energy map may be generated dependent on the pixels in its neighborhood, e.g., using a derivative function. For, example, if a white pixel is surrounded by other white pixels, it may not be considered an important pixel (with respect to a resizing operation). This is because if it is removed, it is not likely to be missed. On the other hand, if a white pixel is surrounded by black pixels, then removing it may be very noticeable and may change the content of the image. Therefore, this pixel may be mapped to a higher value by the energy map.

A content-aware seam carving technique may in various embodiments assign an energy or weight to every pixel, and may use those values to identify one or more seams having a minimal cost with respect to a resizing operation. In other words, the content-aware seam carving technique may use the energy costs of each pixel to identify a path of pixels going from one edge of the image to the opposite edge of the image for which the sum of the energy values has the minimum value. In some embodiments, this determination may be solved efficiently using a technique called dynamic programming or shortest path. Once the lowest-cost seam has been identified, the image may be resized along the seam. For example, if the resizing operation is a reduction operation, the pixels associated with the lowest-cost seam may be removed. In this example, the seam carving operation would remove one pixel per row (because the seam is monotonic), and all the pixels to the right of the seam would be moved one pixel to the left to obtain an image that is one pixel narrower than the input image. By iteratively applying this technique, the image may be reduced to reach a target size and/or aspect ratio. Similarly, if the resizing operation is an expansion operation, the pixels associated with the lowest-cost seam may be replicated, and a copy of each pixel may be inserted into the image to the right of the seam. In this example, the seam carving operation would add one pixel per row, and all the pixels to the right of the seam would be moved one pixel to the right to obtain an image that is one pixel wider than the input image. By iteratively applying this technique, the image may be expanded to reach a target size and/or aspect ratio.

Seam carving may be further illustrated by way of example in FIGS. 1A and 1B. FIG. 1A illustrates an input image 100, which is to be resized. In this example FIG. 1A is to be resized to a target size with an aspect ratio that is shorter (i.e., smaller in the vertical dimension) and wider (i.e., longer in the horizontal dimension) than input image 100. In this example, seam carving techniques may be applied separately in each dimension.

To expand the width of input image 100, one or more low-cost (or lowest-cost) seams of pixels going from top to bottom, such as vertical seam 101, are identified. Input image 100 may then be expanded by replicating the pixels of each of the identified vertical seams (e.g., by making a copy of each pixel of the seam and inserting it into the image to the right of the seam). This may produce a resized image as an intermediate result, in some embodiments. To reduce the height of the input image, one or more low-cost (or lowest-cost) horizontal seams, such as horizontal seam 102, are identified. The resized input image 100 may then be reduced by removing the pixels of the identified horizontal seams. An output image 110, resulting from these two resizing operations, is illustrated in FIG. 1B. Note that in various embodiments, the reduction operation may be performed before the expansion operation, the reduction and expansion operations may be performed in parallel, or the resizing operation may alternate between the replication of vertical seams (e.g., one at a time) and the removal of horizontal seams (e.g., one at a time) until the target size and/or aspect ratio for the output image is reached.

As previously noted, standard seam carving techniques may be too slow for today's demanding interactive environment. One of the bottlenecks in seam carving may be the re-computation of energy values for all of the pixels of an input image between iterations in a given seam carving operation. Using standard seam carving techniques, these computations may comprise on the order of 25% of the computational bandwidth of the operation. For example, as described above, seam carving may include determining an energy value or weight associated with each pixel of an input image that is to be resized. Using standard seam carving techniques, the energy values for all the pixels of an image may be recalculated between iterations (e.g., after each removal or replication of a single seam). In this way, determining the next lowest cost seam in the image would take into account the change made in the previous iteration. For example, a standard seam carving technique may include the following steps:

Let the source image be S

For every seam to be computed:

-   -   1) Find energy (E) for all pixels of S     -   2) Use dynamic programming to find the optimal seam     -   3) Remove the pixels from S belonging to the seam     -   4) Repeat as necessary for the modified source image S

Computing (and re-computing) energy over the entire image, especially for large images, can be highly computationally complex and expensive. In some embodiments, this complexity and expense may be greatly reduced by re-computing energy for only a portion of the image between iterations, rather than re-computing the energy of the entire image. For example, energy may only need to be re-computed in the neighborhood of a removed seam, since energy in the rest of the image may not have been affected by its removal. As a result, instead of computing energy over and over again, the method may include computing energy for the entire image once, and then updating the energy between seam carving iterations only where necessary. Using the example illustrated in FIGS. 1A and 1B, in some embodiments, before determining a next lowest cost vertical seam and/or a next lowest cost horizontal seam after removal of seams 101 and/or 102, only the energy values corresponding to the pixels in the neighborhood of these seams may be re-computed, rather than all of the energy values for input image 100. In this way, a large percentage of the computations typically performed in a seam carving operation may be avoided without compromising the quality of the result.

The neighbors of the pixels of an identified seam, i.e., those pixels for which the energy may be affected by seam removal and/or replication, may in general be dependent on the method used to determine the energy of the image. For example, in various embodiments, energy values mapped to each pixel may be computed as a difference in color values between two or more neighboring pixels, a difference in intensity values between two or more neighboring pixels, a derivative of two or more neighbors' pixel values, an average of two or more neighbors' pixel values, a maximum of two or more neighbors' pixel values, and a minimum of two or more neighbors' pixel values. The neighboring pixels for each of these energy functions may be of various orientations with respect to the target pixel, in different embodiments. For example, one energy function may compute an average of pixel values in a 3×3 pixel area having the target pixel at its center. Another energy function may compute the difference between the value of the pixel on the right of the target pixel and the value of the pixel on the left of the target pixel. Other energy functions are possible and may involve neighboring pixels of any number and/or orientation, in different embodiments.

In one example, neighbors of the identified seam pixels may include a small number of pixels on either side of each seam. In this example, the energy of the image may be computed using a gradient function involving one or more pixels immediately adjacent to each pixel (e.g., pixels that are one pixel to the right, left, top, and/or bottom of each pixel). Therefore, only the energies of the pixels immediately adjacent to each pixel of a replicated or removed seam may need to be re-computed and/or updated in an energy map for the image between iterations.

In some embodiments, the pixels that are considered neighbors of identified seam pixels may be determined programmatically, e.g., based on the energy function employed in the seam carving operation. In other embodiments, they may be determined arbitrarily, or using a default definition. In other words, in some embodiments, the neighborhood of a pixel may be defined to include pixels in a specified number of rows and/or columns surrounding the pixel. For example, in one embodiment, the energy may be re-computed and updated in the image's energy map for all pixels within 4 pixels of an identified seam pixel. In some embodiments, the number and/or orientation of pixels to be re-computed and/or updated may be configurable by a user (e.g., through a graphical user interface).

The methods described above may in some embodiments simplify and/or reduce the number of computations performed during the energy mapping portion of a seam carving operation, thus contributing to implementations of seam carving having improved performance over those employing standard seam carving techniques.

Another of the performance bottlenecks in a seam carving operation may be the retargeting of the image following identification of one or more low-cost (or lowest-cost) seams. For example, many of the images processed by graphic applications are represented by very large amounts of data, e.g., greater than 20 MB (often on the order of 1 GB). As a result, retargeting of such an image (i.e., removal and/or replication of one or more low-costs seams of the image data) may be extremely slow if run sequentially. The methods described herein may in some embodiments improve the speed at which retargeting may be performed during seam carving operations, therefore facilitating implementations of seam carving that are fast enough for user-interactive environments without compromising quality. In some embodiments, performance of seam carving operations may be improved by pre-computing a retargeting matrix mapping each pixel of an input image to a corresponding ordered seam. The retargeting matrix may then be divided into strips in the direction of the desired seam carving operation (e.g., horizontal or vertical strips). Each strip may be processed independently and concurrently (i.e., in parallel) on one or more processors or on a multithreaded processor to retarget the input image.

One method for seam carving that employs a retargeting matrix, as described herein, is illustrated by the flow chart in FIG. 2. In this example, data representing an image to be resized is accessed, as in 200. This data may be accessed in response to being imported into an application configured for image editing, or may be resident in memory accessible to such an application as a result of being imported previously, or as a result of being created and/or modified by the application prior to the desired resizing operation. Note that, as used herein, the term “image editing application” may refer to a graphic application that is specifically directed to image editing, or to any application that includes an image editing component, according to various embodiments. The data accessed may represent a whole image or a portion of an image that is to be resized, in different embodiments. For example, in one embodiment, a user may select a portion of an image on which to perform a resizing operation using a selecting tool or a cropping tool of an image editing application. The user may also select a target size, expansion/reduction target (e.g., a percentage increase or decrease in one or more dimensions) and/or target aspect ratio for a resizing operation using various user interface elements (e.g., pull-down menus, radio buttons, or alphanumeric input fields), in various embodiments. As shown at 200 of FIG. 2, the method may also include initializing an energy map for the image. For example, memory may be allocated for storing the energy values of all the pixels of the input image. In various embodiments, other data structures (e.g., data structures configured to store input image data, intermediate image data, and/or output data for resized images) may also be allocated in memory (not shown).

In this example, respective energy values may be determined for all of the pixels of image, as in 210. The energy values may be determined as described above (e.g., using a derivative function or another parametric function), or by any of various other methods. Dependent on these energy values, the lowest cost seam of the image may be determined, as in 220. The cost of each seam may be determined in various ways in different embodiments, such as by calculating a sum, average, or weighted average of the energy values of the pixels making up the seam. In another example, the cost of each seam may be dependent on a maximum energy value for the pixels of the seam. In other words, a seam may be assigned a higher cost due to the presence of even one high-energy pixel in the seam, because removing that pixel may create an undesirable visual artifact. As previously noted, identifying a seam of the image having a lowest cost may include identifying a shortest path across the image or applying a dynamic programming technique, in some embodiments.

As illustrated at 220 in FIG. 2, the method may include storing a mapping of pixels and ordered seam identifiers, which may be referred to herein as a retargeting matrix. In one embodiment, as each low-cost seam is recognized, an identifier of that seam may be associated with each of the pixels of the seam and/or may be stored in a data structure mapping each pixel of the seam with the seam identifier. Note that each pixel of an image may be associated with a vertical seam and/or with a horizontal seam of which it is a part. For example, each pixel may be associated with one value representing the cost order of the horizontal seam of which it is a part when all the horizontal seams of the image are ordered by cost. Each pixel may also be associated with another value representing the cost order of the vertical seam of which it is a part when all the vertical seams of the image are ordered by cost. One method for generating such a data structure is illustrated in FIG. 3 and described in more detail below.

As illustrated at 230 in FIG. 2, the method may include resizing the image along one or more seams determined to have the lowest cost. For example, if the image is to be reduced, the pixels of one or more of the lowest-cost seams may be removed, while if the image is to be expanded, the pixels of one or more of the lowest-cost seams may be replicated and inserted adjacent to the identified seam(s).

Note that in some embodiments, removal and/or replication of seams may be performed in an iterative manner until a resizing target is achieved (not shown). For example, in one embodiment, a first seam (i.e., the lowest cost seam) may be removed or replicated, but this does not result in a resized image that meets a given resizing target (e.g., a target for size, percentage increase/decrease, and/or aspect ratio). In such embodiments, additional seams (i.e., pixels of successively higher cost seams, according to the stored mapping described above) may be removed or replicated one at a time until the resizing target for the image is met. In another embodiment, the retargeting operation may include a determination of the number of seams that should be removed or replicated in the horizontal and/or vertical directions to achieve the resizing target prior to removing or replicating any of them. In such embodiments, the stored mapping of pixels and corresponding seams (in cost order) may be accessed to determine which pixels of each row and/or column of the image should be removed or replicated by the retargeting operation prior to removing or replicating any of them.

Once the resizing operation is complete, the method may include outputting data representing the resized image, as in 240. For example, the data may be provided to a display component of the application for display of the resized image to the user and/or the data may be stored as in intermediate image by the image editing application for further processing by the application (or another application) or as a final image (e.g., written to main memory, a file, an archive, etc.). Note that the method illustrated in FIG. 2 may in various embodiments be applied to reduction of an image, expansion of an image, or a combination of reduction and expansion operations in order to resize the image to its target size and/or aspect ratio (as in FIGS. 1A-1B).

The methods described herein for iteratively determining the lowest cost seam in an image between seam carving iterations may in some embodiments be applied independently from the performance of seam carving operations themselves. As noted above, rather than iteratively calculating the lowest-cost seam and duplicating it (e.g., one seam at a time) during an expansion operation, the method may include pre-computing the cost of all seams up front, and then duplicating one or more of the lowest-cost seams until a resizing target is met. Similarly, a retargeting operation that reduces an image, or that allows a user to interactively resize an image (e.g., by stretching or moving an edge or corner of the image through a graphical user interface), may access a pre-computed retargeting matrix to determine one or more seams to be removed and/or replicated without having to iteratively determine the next lowest cost seam(s) as the image is modified.

As noted above, a standard seam carving technique may include the following steps:

Let the source image be S

For every seam to be computed:

-   -   1) Find energy (E) for all pixels of S     -   2) Use dynamic programming to find the optimal seam     -   3) Remove the pixels from S belonging to the seam     -   4) Repeat as necessary for the modified source image S

In some embodiments, a method for generating a retargeting matrix may include steps 1 and 2, but may not include removing the pixels of each identified seam from the actual image data, as shown in step 3. Instead, the method may include repeating steps 1 and 2 as if the seam identified in the previous step 2 had been removed, and determining the next lowest cost seam of the image from the updated energy map produced in the current step 1. As the next lowest cost seam is calculated, an indication of the seam cost, the cost order of the seam, and/or the pixels of the seam may be stored in a retargeting matrix for the image. In some embodiments, such a retargeting matrix may include all the information needed to perform interactive retargeting of images without re-computing the image energy and/or the lowest cost seam(s) during the retargeting operation. For example, as a user drags or stretches an edge or corner of an image, the image may be retargeted for display one or more times using the pre-computed retargeting matrix to determine which seam(s) to remove and/or replicate. Once the user saves the image, the retargeting matrix may be re-computed and/or stored in memory for subsequent retargeting operations. In some embodiments, generation of a retargeting matrix may be accelerated using the methods described above for accelerating seam carving operations. For example, when the energy computation at step 1 above is repeated, only the energy values for pixels in the neighborhood of the seam identified in the previous step 2 may be re-computed and updated in the energy map for the image. The updated energy map, with only these changes, may then be used to determine the next lowest seam cost in step 2.

One method for generating a retargeting matrix for use in subsequent image retargeting operations is illustrated in FIG. 3, according to one embodiment. In this example, data representing an image to be retargeted is accessed, as in 300. This data may be accessed in response to being imported into an application configured for image editing, or may be resident in memory accessible to such an application as a result of being imported previously, or as a result of being created and/or modified by the application prior to the desired resizing operation. Note that, as used herein, the term “image editing application” may refer to a graphic application that is specifically directed to image editing, or to any application that includes an image editing component, according to various embodiments. The data accessed may represent a whole image or a portion of an image that is to be resized, in different embodiments. For example, in one embodiment, a user may select a portion of an image on which to perform a resizing operation using a selecting tool or a cropping tool of an image editing application. The user may also select a target size, expansion/reduction target (e.g., a percentage increase or decrease in one or more dimensions) and/or target aspect ratio for a resizing operation using various user interface elements (e.g., pull-down menus, radio buttons, or alphanumeric input fields), in various embodiments. As shown at 300 of FIG. 3, the method may also include initializing an energy map and/or a retargeting matrix for the image. For example, memory may be allocated for storing the energy values of all the pixels of the input image and/or for storing the retargeting matrix. In various embodiments, other data structures (e.g., data structures configured to store input image data, intermediate image data, and/or output data for retargeted images) may also be allocated in memory (not shown).

In this example, respective energy values may be determined for all of the pixels of image, as in 310. The energy values may be determined as described above (e.g., using a derivative function or another parametric function), or by any of various other methods. Dependent on these energy values, the lowest cost seam of the image in one direction (e.g. horizontal or vertical) may be determined, as in 320. The cost of each seam may be determined in various ways in different embodiments, such as by calculating a sum, average, or weighted average of the energy values of the pixels making up the seam. In another example, the cost of each seam may be dependent on a maximum energy value for the pixels of the seam. In other words, a seam may be assigned a higher cost due to the presence of even one high-energy pixel in the seam, because removing that pixel may create an undesirable visual artifact. As previously noted, identifying a seam of the image having a lowest cost may include identifying a shortest path across the image or applying a dynamic programming technique, in some embodiments.

As illustrated at 330 in FIG. 3, the method may include storing in a retargeting matrix an indication of the seam determined to have the lowest cost. For example, the retargeting matrix may be configured to store an identifier of the seam, an indication of the seam cost, the cost order of the seam, and/or an identifier of each of the pixels of the seam in a single entry in the matrix, in various embodiments. In another example, the retargeting matrix may include an entry for each pixel and each entry may include an identifier of a horizontal seam and/or an identifier of a vertical seam of which the pixel is a part. As described above, these identifiers may in some embodiments represent the ordinal number of the corresponding seams, i.e., their position when all seams of the image are ordered by increasing incremental cost, as described herein. In this example, the pixels of the lowest cost seam in this direction may be associated with a seam value of “1.”

In the example illustrated in FIG. 3, if there are more seams in this direction in the image, shown as the positive exit from 340, the method may include determining the next lowest cost seam of the image in this direction, as in 350. The method may also include storing an indication of the next lowest cost seam in the retargeting matrix, shown as the feedback from 350 to 330. For example, each pixel in the second lowest-cost seam (in the current direction) may be associated with a seam value of “2” in a retargeting matrix, and so on. In various embodiments, the energy values of the all the pixels of the image, or of the pixels in the neighborhood of the lowest cost seam, may be updated (e.g., in the energy map for the image) prior to determining the next lowest cost seam (not shown). In such embodiments, once the energy map for the image has been updated, the determination of the next lowest cost seam may be dependent on the updated energy map. As described above, the neighborhood, and therefore the pixels for which the energy values are updated, may be dependent on the energy function employed by the particular seam carving technique to be used in a subsequent retargeting operation. In other embodiments, the energy map may not be updated prior to determining the next lowest cost seam. In such embodiments, the next lowest cost seam of the image may be determined based on the energy values determined for each pixel of the input image at 310, or may be determined based on what the energy values of the image would be if the lowest cost seam had been removed or replicated.

If there are no additional seams in this direction (e.g., horizontal or vertical), shown as the negative exit from 340, the retargeting matrix for this direction may be complete, as in 360. In some embodiments, all of the operations illustrated in 320-360 of FIG. 3 may be repeated (based on the original input image data and energy values determined at 310) to generate a retargeting matrix in the other direction. For example, if an input image is 400×600 pixels (e.g., if it includes 400 pixels in each row and 600 pixels in each column), the vertical seam value associated with each pixel on a given row may be between 1 and 400, depending on which of the 400 vertical seams, numbered in order of increasing incremental cost (as described above), includes the pixel. Similarly, the horizontal seam value associated with each pixel in a given column may be between 1 and 600, depending on which of the 600 horizontal seams, numbered in order of increasing incremental cost (as described above), includes the pixel. Note that in some embodiments, entries of a retargeting matrix may be indexed by their corresponding pixels' locations (e.g., by their associated pixels' row and/or column numbers), according to their position within the input image (i.e., prior to the resizing and/or retargeting operation). In this example, one entry of the retargeting matrix may correspond to a pixel that is a part of the lowest-cost horizontal seam and that is also a part of the third lowest-cost vertical seam. This entry may include a value of “1” in a field representing the horizontal seam order and a value of “3” in a field representing the vertical seam order associated with that pixel. The entry may be indexed according to the position of the corresponding pixel in the original image. For example, if this entry corresponds to the pixel on row 237 and in column 168 of the input image, it may be indexed as (237, 168) in a data structure representing a retargeting matrix for the input image.

As noted above, the methods described herein may facilitate the efficient generation of a retargeting matrix, therefore allowing seam carving operations to be performed in user-interactive applications that exhibit acceptable performance (speed) and produce high quality results (e.g., retargeted images without undesirable artifacts or distortions). Note that in some embodiments, a retargeting matrix may be automatically generated in response to the invocation of an image editing operation. In other embodiments, a retargeting matrix may be automatically generated in response to an image being loaded into a graphics application, and/or in response to a modified version of an image being stored in memory (e.g., following execution of an image editing operation, or when a graphics application is being closed). In still other embodiments, a retargeting matrix may be pre-computed for an image and stored with the image (e.g. by a previous user of an image editing application, or by a third-party provider of the image) so that when the image is opened or otherwise accessed by a graphics application, the pre-computed retargeting matrix may be loaded into the application along with the image data for use in image editing operations.

In various embodiments, a retargeting operation, such as that illustrated as 230 in FIG. 2, may access a pre-computed retargeting matrix of an input image and may remove or replicate pixels of one or more low-cost seams of the image according to the values stored therein. In the example described above, to remove the lowest cost horizontal seam in the image, all pixels associated with a horizontal seam value of “1” may be identified and removed from the image data, or to duplicate the third lowest cost vertical seam, all the pixels associated with a vertical seam value of “3” may be identified and replicated in the image data. Note that for a large image (and corresponding large retargeting matrix), a retargeting operation that sequentially visits data associated with each pixel in the entire retargeting matrix to identify and remove (or replicate) those having a particular horizontal or vertical seam value (or one of several horizontal or vertical seam values, when two or more seams are to be removed or replicated) may be extremely slow.

In some embodiments, a retargeting operation may include dividing a retargeting matrix, such as those described herein, into sub-matrices and processing some or all of them independently and/or in parallel. In some embodiments, such a method may allow the retargeting operation to exploit the processing power of multiple cores present in many modern day computing systems. The method may also ensure that the retargeting operation operates on a data set that can fit into memory. For example, for a horizontal seam carving operation (e.g., one involving the removal or replication of one or more horizontal seams), the retargeting matrix may be divided into two or more sub-matrices, each comprising entries corresponding to pixels in non-overlapping horizontal strips in the image. In this example, these sub-matrices may be processed in parallel on different processors, or by different threads of a multi-threaded multiprocessor. Similarly, for a vertical seam carving operation, the retargeting matrix may be divided into two or more sub-matrices, each comprising entries corresponding to pixels in non-overlapping vertical strips in the image, for parallel processing.

FIG. 4 is a flow diagram illustrating one such method for performing parallel processing of a retargeting matrix in an image resizing operation of a graphics application, according to one embodiment. As illustrated in FIG. 4, the method may include accessing a retargeting matrix for an image to be resized. As described herein, the retargeting matrix may in various embodiments have been provided with the image (e.g., by a third party provider of the image and associated meta-data), or may have been pre-computed by the graphics application in response to accessing or opening an image file, saving an image file, or invoking a resizing operation on an input image. In some embodiments, a single retargeting matrix may be associated with an input image and may include, for each pixel, a horizontal seam value and a vertical seam value identifying horizontal and vertical seams, respectively, that contain the pixel (e.g., ordinal numbers representing the seams' relative costs). In other embodiments, two such retargeting matrices may be associated with an input image, one containing horizontal seam values or identifiers associated with each pixel of the input image and the other containing vertical seam values or identifiers associated with each pixel of the input image.

In this example, the method may include dividing the retargeting matrix into two or more sub-matrices, as in 410. As described herein, each sub-matrix may include entries corresponding to a non-overlapping horizontal or vertical strip in the input image. For example, in embodiments in which a two retargeting matrices are associated with an input image, the method may include dividing the retargeting matrix that includes horizontal seam values into two or more sub-matrices corresponding to horizontal strips in the input image and dividing the retargeting matrix that includes vertical seam values into two or more sub-matrices corresponding to vertical strips in the input image. Similarly, in embodiments in which a single retargeting matrix includes both horizontal and vertical seam values, the method may include dividing the retargeting matrix into two or more sub-matrices corresponding to horizontal strips in the input image and two or more other sub-matrices corresponding to vertical strips in the input image. Each sub-matrix that includes horizontal seam values may include horizontal seam values associated with pixels in a given range of columns of the input image, while each sub-matrix that includes vertical seam values may include vertical seam values associated with pixels in a given range of rows of the input image. For example, one sub-matrix may include horizontal seam values associated with pixels in columns 1-100 of a given input image, while another may include vertical seam values associated with pixels in rows 300-450. Note that in some embodiments, each sub-matrix that includes horizontal seam values may be associated with pixels in the same number of columns and/or each sub-matrix that includes vertical seam values may be associated with pixels in the same number of rows. In other embodiments, not all sub-matrices (e.g. for a given direction) may correspond to the same number of pixels, rows, or columns as other sub-matrices.

As illustrated in FIG. 4, the method may include initiating parallel processing of each sub-matrix on a respective one of a plurality of available processors (or threads thereof) in the execution environment of the graphics application, as in 420. Note that the number of strips into which a retargeting matrix may be sub-divided may in some embodiments be dependent on a number of available processors (or threads thereof) in the execution environment. In some embodiments, the number of sub-matrices into which a retargeting matrix is divided may be equal to, or a multiple of, the number of processors or threads available in the system. For example, in a system that includes 16 available processors, the retargeting matrix (or matrices) may be divided into 8 sub-matrices containing seam values corresponding to pixels in one of 8 non-overlapping horizontal strips in the input image, and 8 sub-matrices containing seam values corresponding to pixels in one of 8 non-overlapping vertical strips in the input image. In this example, all 16 sub-matrices may be processed in parallel on the 16 available processors. In another example, in a system that includes 8 available threads, the retargeting matrix (or matrices) may be divided into 16 sub-matrices corresponding to 8 horizontal strips and 8 vertical strips, and half of these strips may be processed at a time, followed by the other half In other embodiments, the number of sub-matrices into which a retargeting matrix is divided may not be related to the number of available processors or threads, but may be determined arbitrarily or using other methods and/or criteria.

As illustrated in FIG. 4, the method may include, for each applicable sub-matrix being processed, identifying any pixel(s) within the strip represented by the sub-matrix corresponding to one or more low-cost seams identified for removal or replication, as in 430. For example, if the retargeting operation is to remove one horizontal seam of the image (i.e., the lowest-cost horizontal seam), processing each applicable sub-matrix may include searching each sub-matrix that includes horizontal seam values for any pixels associated with a horizontal seam value of “1” (as shown in 430) and removing those pixels from the image data (e.g., removing the pixels from intermediate image data to be displayed to the user following the retargeting operation), as in 440. Note that the pixels of the lowest cost seam may not all be included in the same horizontal strip of the image, since a horizontal seam having a lowest cost may include pixels on different rows of the image, and these rows may be included in different strips when the data associated with the image is sub-divided for parallel processing. Thus, the seam values associated with the pixels of the seam may be included in two or more sub-matrices, in some cases. However, processing of each sub-matrix (for each respective horizontal strip) may be carried out in parallel, since there are no dependencies between the operations performed on each sub-matrix (e.g., between the searches). In another example, if the retargeting operation is to replicate the three lowest-cost vertical seams, processing each sub-matrix may include searching each sub-matrix that includes vertical seam values for any pixels associated with vertical seam values of “1,” “2,” or “3” (as shown in 430) and replicating those pixels in the image data, as in 440. In some embodiments, removing or replicating pixels in an image results in a shifting of pixels in the image. For example, when pixels of a given horizontal seam are removed, all the pixels below the removed pixels may be shifted up by one position in the image, and the image is shortened by one pixel. Similarly, when pixels of a given vertical seam are replicated, all the pixels to the right of the replicated pixels may be shifted one position to the right to make room for the inserted pixels. Note that in some embodiments, this shifting of pixels may be a relatively fast operation. For example, this shifting operation may be especially fast in embodiments in which the image data being processed by a single processor/thread in the retargeting operation (e.g., data for a given image strip corresponding to one of the retargeting sub-matrices) fits in local memory and/or a cache associated with the processor/thread.

Note that in some embodiments, a resizing operation may be applied iteratively, searching for and removing (or replicating) pixels of one seam at a time (e.g., searching for one horizontal or vertical seam value in the applicable sub-matrices at a time). In other embodiments, a resizing operation may be configured to identify a range of two or more seam values for removal or replication, and to search for seam values in this range in a single search of each sub-matrix. In still other embodiments, a given retargeting operation may be directed to both horizontal and vertical resizing, and may be configured to perform them all in parallel (with some processors/threads searching horizontal seam values while others search vertical seam values), to perform them sequentially (e.g., performing parallel processing all of the horizontal strips first, then parallel processing of all of the vertical strips), or to perform them in an alternating fashion (performing one or more parallel searches of horizontal seam values, followed by one or more parallel searches of vertical seam values, followed by additional searches of horizontal seam values, etc.)

Note also that in some embodiments, retargeting operations are always performed on retargeting matrix data pre-computed from original input image data. In such embodiments, during a given interactive resizing operation (e.g., until a resized image is saved or changes thereto are committed), a series of resizing operations may be requested and performed using the pre-computed horizontal and vertical seam values (e.g., by the user dragging a corner or other handle of the image using a graphical user interface), without making any updates to the retargeting matrix or sub-matrices themselves following each change in the size and/or aspect ratio of the image. The intermediate image data produced by these operations may in some embodiments be updated on the fly by repeatedly searching the sub-matrices for pixels to remove or replicate as the user interactively resizes the image. In some embodiments, each of these searches may involve a look-up operation on the data structures representing the sub-matrices, and may be a relatively fast operation when the data set is small enough to fit in memory (e.g., in a cache associated with a given one of the parallel processors or threads).

As noted above, the number of sub-matrices into which a retargeting matrix may be divided may not be equal to the number of processors or threads available for parallel processing. As illustrated in FIG. 4, if, after processing some number of sub-matrices as in the operations shown in 420-440, there are more sub-matrices to be processed, the method may include repeating those operations for additional sub-matrices, until all applicable sub-matrices have been processed. This is shown as the feedback from the positive exit of 450 to 420. Once all applicable sub-matrices have been processed for a given retargeting operation, shown as the negative exit from 450, the method may include providing output data for the retargeted image, as in 460. For example, image data from which pixels have been removed and/or in which pixels have been replicated using the methods illustrated in FIG. 4 may be provided to a display component of the application for display of the resized image to the user and/or the data may be stored as in intermediate image by the image editing application for further processing by the application (or another application) or as a final image (e.g., written to main memory, a file, an archive, etc.).

The methods described herein for resizing and retargeting images (e.g., within a graphics application) may be implemented by a computer system configured to provide the functionality described. FIG. 5 is a block diagram illustrating one embodiment of a computer system 500 configured for implementing the methods described herein. In this example, a graphics application such as graphics application 520 may be configured to perform resizing on image data as part of various editing functions and to render new images according to the resizing. For example, graphics application 520 may perform reductions and/or expansions of various images using seam-based techniques, as described herein, to resize an input image, according to various embodiments. Graphics application 520 may be configured to render the resized image to a separate window, or directly into the same frame buffer containing the input image, in different embodiments.

Graphics application 520 may represent various types of graphics applications, such as painting, publishing, photography, games, animation, and other applications. Additionally, graphics application 520 may utilize a graphics processor 540 when rendering or displaying images according to various embodiments. A graphics processing unit or GPU may be considered a dedicated graphics-rendering device for a personal computer, workstation, game console or other computer system. Modern GPUs may be very efficient at manipulating and displaying computer graphics and their highly parallel structure may make them more effective than typical CPUs for a range of complex graphical algorithms. For example, graphics processor 540 may implement a number of graphics primitive operations in a way that makes executing them much faster than drawing directly to the screen with a host central processing unit (CPU), such as CPU 530. In various embodiments, the methods disclosed herein for generating a retargeting matrix and/or the methods disclosed herein for performing resizing of an image may be implemented by program instructions configured for parallel execution on two or more such GPUs. For example, in some embodiments, two or more sub-matrices of a retargeting matrix (i.e., each corresponding to a horizontal or vertical strip in the image) may be processed in parallel by two or more such GPUs. The GPU 500 may implement one or more application programmer interfaces (APIs) that permit programmers to invoke the functionality of the GPU. Suitable GPUs may be commercially available from vendors such as NVIDIA Corporation, ATI Technologies, and others.

Please note that functionality and/or features described herein as being part of, or performed by, graphics application 520 may, in some embodiments, be part of, or performed by, one or more graphics processors, such as graphics processor 540. As described above, in some embodiments graphics application 520 may be configured to render resized images into a different window than input images.

Resizing of images, as described herein, may be implemented on various types of computer systems. Referring again to FIG. 5, computer system 500 may be any of various types of devices, including, but not limited to, a personal computer system, desktop computer, laptop or notebook computer, mainframe computer system, handheld computer, workstation, network computer, a consumer device, video game console, handheld video game device, application server, storage device, a peripheral device such as a switch, modem, router, or in general any type of computing device.

Graphics application 520, which may be configured to implement the resizing techniques described herein, may be provided as a computer program product, or software, that may include a computer-readable storage medium having stored thereon instructions, which may be used to program a computer system (or other electronic devices) to implement image resizing and/or generation of a retargeting matrix, as described herein. A computer-readable storage medium may include any mechanism for storing information in a form (e.g., software, processing application) readable by a machine (e.g., a computer). The machine-readable storage medium may include, but is not limited to, magnetic storage medium (e.g., floppy diskette); optical storage medium (e.g., CD-ROM); magneto optical storage medium; read only memory (ROM); random access memory (RAM); erasable programmable memory (e.g., EPROM and EEPROM); flash memory; electrical, or other types of medium suitable for storing program instructions. In addition, program instructions may be communicated using optical, acoustical or other form of propagated signal (e.g., carrier waves, infrared signals, digital signals, or other types of signals or mediums.).

As illustrated in FIG. 5, computer system 500 may include one or more processor units (CPUs) 530. Processors 530 may be implemented using any desired architecture or chip set, such as the SPARC™ architecture, an x86-compatible architecture from Intel Corporation or Advanced Micro Devices, or another architecture or chipset capable of processing data, and may in various embodiments include multiple processors, a single threaded processor, a multi-threaded processor, a multi-core processor, or any other type of general-purpose or special-purpose processor. Note that in various embodiments, the methods disclosed herein for generating a retargeting matrix and/or the methods disclosed herein for performing resizing of an image may be implemented by program instructions configured for parallel execution on two or more such CPUs. For example, in some embodiments, two or more sub-matrices of a retargeting matrix (i.e., each corresponding to a horizontal or vertical strip in the image) may be processed in parallel by two or more such CPUs. Any desired operating system(s) may be run on computer system 500, such as various versions of Unix, Linux, Windows™ from Microsoft Corporation, MacOS™ from Apple Corporation, or any other operating system that enables the operation of software on a hardware platform.

The computer system 500 may also include one or more system memories 510 (e.g., one or more of cache, SRAM, DRAM, RDRAM, EDO RAM, DDR RAM, SDRAM, Rambus RAM, EEPROM, or other memory type), or other types of RAM or ROM) coupled to other components of computer system 500 via interconnect 560. Memory 510 may include other types of memory as well, or combinations thereof. One or more of memories 510 may include program instructions 515 executable by one or more of processors 530 to implement aspects of the image resizing techniques described herein. Program instructions 515, which may include program instructions configured to implement graphics application 520, may be partly or fully resident within the memory 510 of computer system 500 at any point in time. Alternatively, program instructions 515 may be provided to GPU 540 for performing resizing operations (or portions thereof) on GPU 540 using one or more of the techniques described herein. In some embodiments, the techniques described herein may be implemented by a combination of program instructions 515 executed on one or more processors 530 and one or more GPUs 540, respectively. Program instructions 515 may also be stored on an external storage device (not shown) accessible by the processor(s) 530 and/or GPU 540, in some embodiments. Any of a variety of such storage devices may be used to store the program instructions 515 in different embodiments, including any desired type of persistent and/or volatile storage devices, such as individual disks, disk arrays, optical devices (e.g., CD-ROMs, CD-RW drives, DVD-ROMs, DVD-RW drives), flash memory devices, various types of RAM, holographic storage, etc. The storage devices may be coupled to the processor(s) 530 and/or GPU 540 through one or more storage or I/O interfaces including, but not limited to, interconnect 560 or network interface 550, as described herein. In some embodiments, the program instructions 515 may be provided to the computer system 500 via any suitable computer-readable storage medium including memory 510 and/or external storage devices described above. Memory 510 may also be configured to implement one or more data structures 525, such as an energy map, a retargeting matrix, various sub-matrices of a retargeting matrix, and/or structures configured to store data representing one or more input images, output images, or intermediate images. Data structures 525 may be accessible by processor(s) 530 and/or GPU 540 when executing graphics application 520 or other program instructions 515.

As shown in FIG. 5, processor(s) 530 may be coupled to one or more of the other illustrated components by at least one communications bus, such as interconnect 560 (e.g., a system bus, LDT, PCI, ISA, or other communication bus type), and a network interface 550 (e.g., an ATM interface, an Ethernet interface, a Frame Relay interface, or other interface). The CPU 530, the network interface 550, and the memory 510 may be coupled to the interconnect 560. It should also be noted that one or more components of system 500 might be located remotely and accessed via a network.

As noted above, in some embodiments, memory 510 may include program instructions 515, comprising program instructions configured to implement graphics application 520, as described herein. Graphics application 520 may be implemented in various embodiments using any desired programming language, scripting language, or combination of programming languages and/or scripting languages, e.g., C, C++, C#, Java™, Perl, etc. For example, in one embodiment, graphics application 520 may be JAVA based, while in another embodiments, it may be implemented using the C or C++ programming languages. In other embodiments, graphics application 520 may be implemented using specific graphic languages specifically for developing programs executed by specialize graphics hardware, such as GPU 540. In addition, graphics application 520 may be embodied on memory specifically allocated for use by graphics processor(s) 540, such as memory on a graphics board including graphics processor(s) 540. Thus, memory 510 may represent dedicated graphics memory as well as general-purpose system RAM, in various embodiments. Memory 510 may in some embodiments also include a data store configured to store image data for one or more input images and/or output images, in various embodiments. Other information not described herein may be included in memory 510 and may be used to implement the methods described herein and/or other functionality of computer system 500.

Network interface 550 may be configured to enable computer system 500 to communicate with other computers, systems or machines, such as across a network. Network interface 550 may use standard communications technologies and/or protocols, and may utilize links using technologies such as Ethernet, 802.11, integrated services digital network (ISDN), digital subscriber line (DSL), and asynchronous transfer mode (ATM) as well as other communications technologies. Similarly, the networking protocols used on a network to which computer system 500 is interconnected may include multiprotocol label switching (MPLS), the transmission control protocol/Internet protocol (TCP/IP), the User Datagram Protocol (UDP), the hypertext transport protocol (HTTP), the simple mail transfer protocol (SMTP), and the file transfer protocol (FTP), among other network protocols. The data exchanged over such a network by network interface 550 may be represented using technologies, languages, and/or formats, such as the hypertext markup language (HTML), the extensible markup language (XML), and the simple object access protocol (SOAP) among other data representation technologies. Additionally, all or some of the links or data may be encrypted using any suitable encryption technologies, such as the secure sockets layer (SSL), Secure HTTP and/or virtual private networks (VPNs), the international data encryption standard (DES or IDEA), triple DES, Blowfish, RC2, RC4, RC5, RC6, as well as other data encryption standards and protocols. In other embodiments, custom and/or dedicated data communications, representation, and encryption technologies and/or protocols may be used instead of, or in addition to, the particular ones described above.

GPUs, such as GPU 540 may be implemented in a number of different physical forms. For example, GPU 540 may take the form of a dedicated graphics card, an integrated graphics solution and/or a hybrid solution. GPU 540 may interface with the motherboard by means of an expansion slot such as PCI Express Graphics or Accelerated Graphics Port (AGP) and thus may be replaced or upgraded with relative ease, assuming the motherboard is capable of supporting the upgrade. However, a dedicated GPU is not necessarily removable, nor does it necessarily interface the motherboard in a standard fashion. The term “dedicated” refers to the fact that hardware graphics solution may have RAM that is dedicated for graphics use, not to whether the graphics solution is removable or replaceable. Dedicated GPUs for portable computers may be interfaced through a non-standard and often proprietary slot due to size and weight constraints. Such ports may still be considered AGP or PCI express, even if they are not physically interchangeable with their counterparts. As illustrated in FIG. 5, memory 510 may represent any of various types and arrangements of memory, including general-purpose system RAM and/or dedication graphics or video memory.

Integrated graphics solutions, or shared graphics solutions are graphics processors that utilize a portion of a computer's system RAM rather than dedicated graphics memory. For instance, modern desktop motherboards normally include an integrated graphics solution and have expansion slots available to add a dedicated graphics card later. As a GPU may be extremely memory intensive, an integrated solution finds itself competing for the already slow system RAM with the CPU as the integrated solution has no dedicated video memory. For instance, system RAM may experience a bandwidth between 2 GB/s and 8 GB/s, while most dedicated GPUs enjoy from 15 GB/s to 30 GB/s of bandwidth. Hybrid solutions may also share memory with the system memory, but may have a smaller amount of memory on-board than discrete or dedicated graphics cards to make up for the high latency of system RAM. Data communicated between the graphics processing unit 540 and the rest of the computer system 500 may travel through a graphics card slot or other interface, such as interconnect 560 of FIG. 5.

Computer system 500 may also include one or more additional I/O interfaces, such as interfaces for one or more user input devices 570, or such devices may be coupled to computer system 500 via network interface 550. For example, computer system 500 may include interfaces to a keyboard, a mouse or other cursor control device, a joystick, or other user input devices 570, in various embodiments. Additionally, the computer system 500 may include one or more displays (not shown), coupled to processors 530 and/or other components via interconnect 560 or network interface 550. Such input/output devices may be configured to allow a user to interact with graphics application 520 to request various resizing operations and/or to specify various parameters, thresholds, and/or other configurable options available to the user when editing images executing graphic application 520. It will be apparent to those having ordinary skill in the art that computer system 500 may also include numerous other elements not shown in FIG. 5.

Note that program instructions 515 may be configured to implement a graphic application 520 as a stand-alone application, or as a module of another graphics application or graphics library, in various embodiments. For example, in one embodiment program instructions 515 may be configured to implement graphics applications such as painting, publishing, photography, games, animation, and/or other applications, and may be configured to resize images as part of one or more of these graphics applications. In another embodiment, program instructions 515 may be configured to implement the resizing techniques described herein in one or more functions called by another graphics application executed on GPU 540 and/or processor(s) 530. In various embodiments, program instructions 515 may be configured to pre-compute a retargeting matrix as a stand-alone utility, and/or to pre-compute a retargeting matrix, sub-divide a retargeting matrix, and/or process the information provided in such a retargeting matrix as a utility provided in a graphics application or as part of performing an image resizing operation in a graphics application. Program instructions 515 may also be configured to render images and present them on one or more displays as the output of a resizing operation and/or to store image data for resized images in memory 510 and/or an external storage device(s), in various embodiments. For example, a graphics application 520 included in program instructions 515 may utilize GPU 540 when resizing, rendering, or displaying images in some embodiments.

While various resizing techniques have been described herein with reference to various embodiments, it will be understood that these embodiments are illustrative and are not meant to be limiting. Many variations, modifications, additions, and improvements are possible. More generally, various techniques are described in the context of particular embodiments. For example, the blocks and logic units identified in the description are for ease of understanding and are not meant to be limiting to any particular embodiment. Functionality may be separated or combined in blocks differently in various realizations or described with different terminology. In various embodiments, actions or functions described herein may be performed in a different order than illustrated or described. Any of the operations described may be performed programmatically (i.e., by a computer according to a computer program). Any of the operations described may be performed automatically (i.e., without user intervention).

The embodiments described herein are meant to be illustrative and not limiting. Accordingly, plural instances may be provided for components described herein as a single instance. Boundaries between various components, operations and data stores are somewhat arbitrary, and particular operations are illustrated in the context of specific illustrative configurations. Other allocations of functionality are envisioned and may fall within the scope of claims that follow. Finally, structures and functionality presented as discrete components in the exemplary configurations may be implemented as a combined structure or component. These and other variations, modifications, additions, and improvements may fall within the scope as defined in the claims that follow.

Although the embodiments above have been described in detail, numerous variations and modifications will become apparent to those skilled in the art once the above disclosure is fully appreciated. It is intended that the following claims be interpreted to embrace all such variations and modifications. 

1. A system, comprising: one or more processors; and a memory coupled to the one or more processors and storing program instructions executable by the one or more processors to implement: accessing a retargeting matrix for an image, wherein the retargeting matrix is a data structure comprising an indication of a cost order for each of a plurality of seams in the image, wherein a seam represents a monotonic path of pixels from one edge of the image to the opposite edge of the image, wherein the pixels included in each seam are dependent on the respective energy values of the pixels, and wherein in the retargeting matrix the indication of the cost order for each seam is associated with each of the pixels of the seam; dividing the retargeting matrix into a plurality of sub-matrices, wherein each sub-matrix comprises the indication of the cost order for each seam of a subset of the plurality of seams in a respective portion of the image, and wherein each subset of the plurality of seams comprises two or more seams; identifying, in each of two or more of the plurality of sub-matrices, any pixels associated with an indication of a lowest-cost seam in the image; and removing or replicating the identified pixels in the image to produce a resized version of the image; wherein said identifying and said removing or replicating are performed independently and concurrently on the one or more processors for each of the two or more of the plurality of sub-matrices.
 2. The system of claim 1, wherein the retargeting matrix further comprises, for each pixel of the image, one or more of: an identifier of a seam of which it is a part, and a cost of the seam of which it is a part.
 3. The system of claim 1, wherein the retargeting matrix further comprises, for each of the plurality of seams in the image, one or more of: an identifier of the seam, a cost of the seam, and an identifier of each pixel of the seam.
 4. The system of claim 1, wherein the lowest-cost seam is a lowest-cost horizontal seam in the image; and wherein each respective portion of the image comprises a horizontal strip of the image.
 5. The system of claim 1, wherein the lowest-cost seam is a lowest-cost vertical seam in the image; and wherein each respective portion of the image comprises a vertical strip of the image.
 6. The system of claim 1, wherein the program instructions are further executable to implement: identifying, in another two or more of the plurality of sub-matrices, any additional pixels associated with an indication of the lowest-cost seam in the image; and removing or replicating the additional pixels in the image to produce the resized version of the image; wherein said identifying any additional pixels and said removing or replicating the additional pixels are performed independently and concurrently on the one or more processors for each of the other two or more of the plurality of sub-matrices.
 7. The system of claim 1, wherein the program instructions are further executable to implement: identifying, in each of the two or more of the plurality of sub-matrices, any pixels associated with an indication of a next lowest-cost seam in the image; and removing or replicating the identified pixels of a next lowest-cost seam in the image to produce a further resized version of the image.
 8. The system of claim 1, wherein the program instructions are further executable to implement: receiving user input indicating a request to resize the image; and wherein said accessing, said dividing, said identifying, and said removing or replicating are performed in response to said receiving.
 9. The system of claim 8, wherein in response to receiving user input indicating a request to reduce the size of the image, said removing or replicating the identified pixels in the image comprises removing the identified pixels.
 10. The system of claim 8, wherein in response to receiving user input indicating a request to expand the image, said removing or replicating the identified pixels in the image comprises replicating the identified pixels and inserting the replicated pixels into the image.
 11. The system of claim 8, wherein the program instructions are further executable to implement: receiving user input indicating a second request to resize the image; and repeating said identifying and said removing or replicating in response to said receiving user input indicating the second request.
 12. The system of claim 1, wherein the cost order of each of the plurality of seams in the image is dependent on one or more of: a sum of the respective energy values of all pixels of the seam, an average of the respective energy values of all pixels of the seam, a weighted average of the respective energy values of all pixels of the seam, and a maximum value of the respective energy values of all pixels of the seam.
 13. The system of claim 1, wherein the one or more processors comprise at least one of: a general-purpose central processing unit (CPU) and a graphics processing unit (GPU).
 14. A non-transitory, computer-readable storage medium, storing program instructions computer-executable to implement: accessing a retargeting matrix for an image, wherein the retargeting matrix is a data structure comprising an indication of a cost order for each of a plurality of seams in the image, wherein a seam represents a monotonic path of pixels from one edge of the image to the opposite edge of the image, wherein the pixels included in each seam are dependent on the respective energy values of the pixels, and wherein in the retargeting matrix the indication of the cost order for each seam is associated with each of the pixels of the seam; dividing the retargeting matrix into a plurality of sub-matrices, wherein each sub-matrix comprises the indication of the cost order for each seam of a subset of the plurality of seams in a respective portion of the image, and wherein each subset of the plurality of seams comprises two or more seams; identifying, in each of two or more of the plurality of sub-matrices, any pixels associated with an indication of a lowest-cost seam in the image; and removing or replicating the identified pixels in the image to produce a resized version of the image; wherein said identifying and said removing or replicating are performed independently and concurrently for each of the two or more of the plurality of sub-matrices.
 15. The storage medium of claim 14, wherein the retargeting matrix further comprises, for each pixel of the image, one or more of: an identifier of a seam of which it is a part, and a cost of the seam of which it is a part.
 16. The storage medium of claim 14, wherein the retargeting matrix further comprises, for each of the plurality of seams in the image, one or more of: an identifier of the seam, a cost of the seam, and an identifier of each pixel of the seam.
 17. The storage medium of claim 14, wherein the lowest-cost seam is a lowest-cost horizontal seam in the image; and wherein each respective portion of the image comprises a horizontal strip of the image.
 18. The storage medium of claim 14, wherein the lowest-cost seam is a lowest-cost vertical seam in the image; and wherein each respective portion of the image comprises a vertical strip of the image.
 19. The storage medium of claim 14, wherein the program instructions are further executable to implement: identifying, in another two or more of the plurality of sub-matrices, any additional pixels associated with an indication of the lowest-cost seam in the image; and removing or replicating the additional pixels in the image to produce the resized version of the image; wherein said identifying any additional pixels and said removing or replicating the additional pixels are performed independently and concurrently for each of the other two or more of the plurality of sub-matrices.
 20. The storage medium of claim 14, wherein the program instructions are further executable to implement: identifying, in each of the two or more of the plurality of sub-matrices, any pixels associated with an indication of a next lowest-cost seam in the image; and removing or replicating the identified pixels of a next lowest-cost seam in the image to produce a further resized version of the image.
 21. The storage medium of claim 14, wherein the program instructions are further executable to implement: receiving user input indicating a request to resize the image; and wherein said accessing, said dividing, said identifying, and said removing or replicating are performed in response to said receiving.
 22. The storage medium of claim 21, wherein the program instructions are further executable to implement: receiving user input indicating a second request to resize the image; and repeating said identifying and said removing or replicating in response to said receiving user input indicating the second request.
 23. The storage medium of claim 14, wherein the cost order of each of the plurality of seams in the image is dependent on one or more of: a sum of the respective energy values of all pixels of the seam, an average of the respective energy values of all pixels of the seam, a weighted average of the respective energy values of all pixels of the seam, and a maximum value of the respective energy values of all pixels of the seam.
 24. A method, comprising: performing, by one or more computers: accessing a retargeting matrix for an image, wherein the retargeting matrix is a data structure comprising an indication of a cost order for each of a plurality of seams in the image, wherein a seam represents a monotonic path of pixels from one edge of the image to the opposite edge of the image, wherein the pixels included in each seam are dependent on the respective energy values of the pixels, and wherein in the retargeting matrix the indication of the cost order for each seam is associated with each of the pixels of the seam; dividing the retargeting matrix into a plurality of sub-matrices, wherein each sub-matrix comprises the indication of the cost order for each seam of a subset of the plurality of seams in a respective portion of the image, and wherein each subset of the plurality of seams comprises two or more seams; identifying, in each of two or more of the plurality of sub-matrices, any pixels associated with an indication of a lowest-cost seam in the image; and removing or replicating the identified pixels in the image to produce a resized version of the image; wherein said identifying and said removing or replicating are performed independently and concurrently for each of the two or more of the plurality of sub-matrices.
 25. The method of claim 24, wherein the retargeting matrix further comprises, for each pixel of the image, one or more of: an identifier of a seam of which it is a part, and a cost of the seam of which it is a part.
 26. The method of claim 24, wherein the retargeting matrix further comprises, for each of the plurality of seams in the image, one or more of: an identifier of the seam, a cost of the seam, and an identifier of each pixel of the seam.
 27. The method of claim 24, wherein the lowest-cost seam is a lowest-cost horizontal seam in the image; and wherein each respective portion of the image comprises a horizontal strip of the image.
 28. The method of claim 24, wherein the lowest-cost seam is a lowest-cost vertical seam in the image; and wherein each respective portion of the image comprises a vertical strip of the image.
 29. The method of claim 24, further comprising: identifying, in another two or more of the plurality of sub-matrices, any additional pixels associated with an indication of the lowest-cost seam in the image; and removing or replicating the additional pixels in the image to produce the resized version of the image; wherein said identifying any additional pixels and said removing or replicating the additional pixels are performed independently and concurrently for each of the other two or more of the plurality of sub-matrices.
 30. The method of claim 24, further comprising: identifying, in each of the two or more of the plurality of sub-matrices, any pixels associated with an indication of a next lowest-cost seam in the image; and removing or replicating the identified pixels of a next lowest-cost seam in the image to produce a further resized version of the image.
 31. The method of claim 24, further comprising: receiving user input indicating a request to resize the image; wherein said accessing, said dividing, said identifying, and said removing or replicating are performed in response to said receiving.
 32. The method of claim 31, further comprising: receiving user input indicating a second request to resize the image; and repeating said identifying and said removing or replicating in response to said receiving user input indicating the second request.
 33. The method of claim 24, wherein the cost order of each of the plurality of seams in the image is dependent on one or more of: a sum of the respective energy values of all pixels of the seam, an average of the respective energy values of all pixels of the seam, a weighted average of the respective energy values of all pixels of the seam, and a maximum value of the respective energy values of all pixels of the seam. 